<#include "overall_header.html">

						<div style="float:right;">
							<#if se_page.edit_button??><a class="button2" href="${sf_configs.root_path}/ticketedit${sf_configs.extension}?id=${se_page.ticket.id}">${L("global.edit")}</a></#if>
							<a class="button2" href="${sf_configs.root_path}/ticketcommentedit${sf_configs.extension}?ticket_id=${se_page.ticket.id}">${L("comment.comment-add")}</a>
						</div>

						<h1>${L("nav.ticketview")} - ${se_page.ticket.subject}</h1>
						<p>
							${L("project")}: <#if se_page.ticket.project??>${se_page.ticket.project.name}</#if>
							| ${L("project.role")}: <#if se_page.project_to_user??>${L("project.role."+se_page.project_to_user.role)}</#if>
							| ${L("tag.tags")}: <#if se_page.ticket.tags?? && se_page.ticket.tags?size &gt; 0><#list se_page.ticket.tags as tag><a href="${sf_configs.root_path}/ticket${sf_configs.extension}?tag_id=${tag.id}">${tag.name}</a><#if tag_has_next>, </#if></#list></#if>
						</p>

						<table cellspacing="1">
							<caption>${L("ticket.information")}</caption>
							<colgroup>
								<col width="130" class="col1"><col width="250" class="col2"><col width="130" class="col1"><col class="col2">
							</colgroup>
							<tbody>
								<tr>
									<td>${L("ticket.priority")}</td>
									<td>${L("ticket.priority."+se_page.ticket.priority)}</td>
									<td>${L("ticket.status")}</td>
									<td>${L("ticket.status."+se_page.ticket.status)}</td>
								</tr>
								<tr>
									<td>${L("ticket.owner")}</td>
									<td>
										<#if se_page.ticket.owner??>
										<a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${se_page.ticket.ownerId}">${se_page.ticket.owner.name}</a>
										<#else>
										<a class="button2" href="${sf_configs.root_path}/ticketassign${sf_configs.extension}?ticket_id=${se_page.ticket.id}&owner_id=${se_session.session_uuid}">${L("ticket.accept")}</a>
										</#if></td>
									<td>${L("ticket.due-date")}</td>
									<td><#if se_page.ticket.dueDate??><span <#if .now?date &gt; se_page.ticket.dueDate?date> style="color:#990000;"</#if>>${se_page.ticket.dueDate?string("yyyy-MM-dd")}</span></#if></td>
								</tr>
								<tr>
									<td>${L("ticket.creator")}</td>
									<td><#if se_page.ticket.creator??><a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${se_page.ticket.creatorId}">${se_page.ticket.creator.name}</a></#if></td>
									<td>${L("ticket.create-time")}</td>
									<td>${se_page.ticket.createTime?string("yyyy-MM-dd HH:mm")}</td>
								</tr>
								<tr>
									<td>${L("ticket.updater")}</td>
									<td><#if se_page.ticket.updater??><a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${se_page.ticket.updaterId}">${se_page.ticket.updater.name}</a></#if></td>
									<td>${L("ticket.update-time")}</td>
									<td>${se_page.ticket.updateTime?string("yyyy-MM-dd HH:mm")}</td>
								</tr>
								<tr>
									<td>${L("ticket.contributors")}</td>
									<td colspan="3">
										<#list se_page.ticket.users as contributor>
										<a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${contributor.userId}" title="${contributor.createTime?string("yyyy-MM-dd HH:mm")}">${contributor.user.name}</a><#if contributor_has_next>, </#if>
										</#list>
									</td>
								</tr>
								<tr>
									<td>${L("ticket.content")}</td>
									<td colspan="3">
										${se_page.ticket.content}
									</td>
								</tr>
								<#if se_page.ticket.attachments?? && se_page.ticket.attachments?size &gt; 0>
								<tr>
									<td>${L("attachment.attachments")}</td>
									<td colspan="3">
										<#list se_page.ticket.attachments as attachment>
										<div style="background-color: #EEE; border: 1px solid #CCCFD3; padding:5px; margin: 0 3px 3px 0; height:60px; overflow:hidden; float:left;">
										<#if attachment.type == 1><a href="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" title="${attachment.name?html} ${attachment.formattedSize?html}" target="_blank">
										<img src="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" border="0" width="150" /></a>
										<#else><a href="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" title="${attachment.name?html} ${attachment.formattedSize?html}" target="_blank"><i>${attachment.name}</i></a><br />${attachment.formattedSize?html}</#if>
										</div>
										</#list>
									</td>
								</tr>
								</#if>
								<#if se_page.ticket.ownerId == se_session.session_uuid>
								<tr>
									<td></td>
									<td colspan="3">
										<form action="${sf_configs.root_path}/ticketupdate${sf_configs.extension}" method="post" id="ticket_update">
											${L("ticket.priority")}:<select id="priority" name="priority">${se_page.priority_options}</select>
											${L("ticket.status")}:<select id="status" name="status">${se_page.status_options}</select>
											${L("ticket.owner")}:<select id="project_id" name="project_id">${se_page.project_options}</select>
											<select id="owner_id" name="owner_id">${se_page.owner_options}</select>
											<input type="hidden" name="ticket_id" value="${se_page.ticket.id}"/>
											<input type="hidden" name="redirect" value="${sf_configs.root_path}/ticketview${sf_configs.extension}?id=${se_page.ticket.id}"/>
											<input type="hidden" name="form_submit" value="1"/>
											<input type="submit" value="${L("global.update")}" name="form_submit" class="button1">
										</form>
									</td>
								</tr>
								</#if>
								<tr>
									<td><a name="comments">${L("comment.comments")}</td>
									<td colspan="3">
										<#if se_page.ticket.comments?? && se_page.ticket.comments?size &gt; 0>
										<table>
											<#list se_page.ticket.comments as comment> 
											<tr class="row<#if (comment_index % 2) == 0>2<#else>1</#if>">
												<td>
													<#if comment.creatorId == se_session.session_uuid><div style="float:right;margin:5px 5px 0 0"><a class="button2" href="${sf_configs.root_path}/ticketcommentedit${sf_configs.extension}?id=${comment.id}">${L("global.edit")}</a></div></#if>
													<#if comment.creator??><a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${comment.creatorId}">${comment.creator.name}</a></#if>
													<span class="timestamp">${comment.createTime?string("yyyy-MM-dd HH:mm")}</span>
													<#if comment.updateTime?date &gt; comment.createTime?date>
													<em>Last updated by <#if comment.updater??><a href="${sf_configs.root_path}/userview${sf_configs.extension}?id=${comment.updaterId}">${comment.updater.name}</a></#if>
													<span class="timestamp">${comment.updateTime?string("yyyy-MM-dd HH:mm")}</span></em>
													</#if>

													<div style="clear:both;margin:5px;"></div>
													<div>${comment.content}</div>

													<#if comment.attachments?? && comment.attachments?size &gt; 0>
													<#list comment.attachments as attachment>
													<div style="background-color: #EEE; border: 1px solid #CCCFD3; padding:5px; margin: 0 3px 3px 0; height:60px; overflow:hidden; float:left;">
														<#if attachment.type == 1><a href="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" title="${attachment.name?html} ${attachment.formattedSize?html}" target="_blank">
														<img src="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" border="0" width="150" /></a>
														<#else><a href="${sf_configs.root_path}/attachmentdownload${sf_configs.extension}?id=${attachment.id}" title="${attachment.name?html} ${attachment.formattedSize?html}" target="_blank"><i>${attachment.name}</i></a><br />${attachment.formattedSize?html}</#if>
													</div>
													</#list>
													</#if>
													
													<div style="clear:both;"></div>
												</td>
											</tr>
											</#list>
										</table>
										<#else>
										${L("comment.no-comments")}
										</#if>
									</td>
								</tr>
							</tbody>
						</table>

						<table cellspacing="1">
							<caption>${L("comment.quick-comment")}</caption>
							<colgroup>
								<col width="130" class="col1"><col class="col2">
							</colgroup>
							<tbody>
								<tr>
									<td></td>
									<td>
										<form action="${sf_configs.root_path}/ticketcommentadd${sf_configs.extension}" method="post" id="comment_add">
											<textarea class="mceEditor" id="comment_content" name="comment_content" style="height: 200px; width:600px;"></textarea>
											<script type="text/javascript">
												tinyMCE.init({
													theme : "advanced",
													theme_advanced_toolbar_location : "top",
													theme_advanced_toolbar_align : "left",
													theme_advanced_buttons3 : "",
													theme_advanced_disable : "image,formatselect,styleselect",
													width:"600",
													mode : "specific_textareas",
													external_image_list_url : "attachmentfortinymce",
													valid_elements : "-code,-pre,address,-h1,-h2,-h3,-h4,-h5,-h6,hr,p,div[id|name|align|style],a[href|target=_blank],strong/b,br,-ul,-li,em/i,u,-table[border=0|cellspacing|cellpadding],-tr,#td,#th,col,colgroup,caption,thead,tbody,img[style|src|alt|width]",
													editor_selector : /(mceEditor)/
												});
											</script>
											<input type="hidden" name="ticket_id" value="${se_page.ticket.id}"/>
											<input type="hidden" name="redirect" value="${sf_configs.root_path}/ticketview${sf_configs.extension}?id=${se_page.ticket.id}#comments"/>
											<input type="hidden" name="form_submit" value="1"/><br />
											<input type="submit" value="${L("global.submit")}" name="form_submit" class="button1">
										</form>
									</td>
								</tr>
							</tbody>
						</table>

						<div class="clearfix">&nbsp;</div>
						<caption><a href="${sf_configs.root_path}/acp/operationlog${sf_configs.extension}?obj_type=3&obj_id=${se_page.ticket.id}" title="${L("log.browse-all")}">${L("log.operationlogs")}</a></caption>
						<table cellspacing="1">
							<thead>
								<tr>
									<th width="150">${L("log.time")}</th>
									<th width="180">${L("log.action")}</th>
									<th>${L("log.parameters")}</th>
									<th width="120" style="text-align: center;">${L("log.user-name")}</th>
								</tr>
							</thead>
							<tbody>
								<#if se_page.ticket.operationLogs??><#list se_page.ticket.operationLogs as operationLog> 
								<tr class="row<#if (operationLog_index % 2) == 0>1<#else>2</#if>">
									<td>${operationLog.time?string('yyyy-MM-dd HH:mm:ss')}</td>
									<td><#if L("nav."+operationLog.action)??>${L("nav."+operationLog.action)}<#else>${operationLog.action}</#if></td>
									<td>
										<#if operationLog.parametersMap??><#list operationLog.parametersMap?keys as paramKey>${paramKey}<#if paramKey_has_next>, </#if></#list></#if>
									</td>
									<td><#if operationLog.user??>${operationLog.user.name}<#else>${operationLog.userId}</#if></td>
								</tr>
								</#list></#if> 
							</tbody>
						</table>
						<script type="text/javascript">
							$('#project_id').change(function() {
								var projectId = $('#project_id option:selected').val();
								$.ajax({
									type			: 'GET',
									url			: '${sf_configs.root_path}/json-projectusers${sf_configs.extension}',
									data			: {"project_id":projectId},
									cache		: false,
									dataType	: "json",
									success	: function(data){
										var dropdown = '<option value="0" title="--">--</option>';
										$.each(data, function(i) {
											var selected = (data[i].id == ${se_page.ticket.ownerId}) ? 'selected' : '';
											dropdown +='<option value="'+data[i].id+'" title="'+data[i].name+'" '+selected+'>'+data[i].name+'</option>';
										});
										$('#owner_id').html(dropdown);
									}
								})
							}).change();

						</script>

<#include "overall_footer.html">
